package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.entity.SkuInfo;
import com.atguigu.gmall.product.service.SkuInfoService;
import com.atguigu.gmall.product.vo.SkuInfoVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lfy
 * @Description
 * @create 2022-11-01 11:21
 */
@RequestMapping("/admin/product")
@RestController
public class SkuController {


    @Autowired
    SkuInfoService skuInfoService;
    /**
     * 获取sku分页列表数据
     * @param pn
     * @param ps
     * @return
     */
    @GetMapping("/list/{pn}/{ps}")
    public Result list(@PathVariable("pn") Long pn,
                       @PathVariable("ps") Long ps){
        Page<SkuInfo> page = new Page<>(pn,ps);
        Page<SkuInfo> result = skuInfoService.page(page);

        return Result.ok(result);
    }


    /**
     * 保存sku
     * @param vo
     * @return
     */
    @PostMapping("/saveSkuInfo")
    public Result saveSkuInfo(@RequestBody SkuInfoVo vo){

        //哈哈
        skuInfoService.saveSkuInfo(vo);
        //呵呵

        //嘿嘿11

        return Result.ok();
    }
}
